import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';

// const target = 'https://www.xingtuobao.com/control/h5'

const target = 'http://192.168.0.131:9090/control/h5'
// https://vitejs.dev/config/
export default defineConfig({
  base: '/jsp/etc/',
  plugins: [
    vue(),
    vueJsx(),
    Components({
      resolvers: [VantResolver()],
    }), //按需加载
  ],
  server: {
    port: 4000,
    proxy: {
      // 选项写法
      '^/app': {
        target: target,
        changeOrigin: true,
        rewrite: path => path
      }
    },
    hmr: {
      overlay: false
    },
    host: '0.0.0.0'
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
